/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.shop.web.order;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.product.entity.catalog.GenCatalog;
import com.thinkgem.jeesite.modules.product.entity.product.GenProduct;
import com.thinkgem.jeesite.modules.product.service.catalog.GenCatalogService;
import com.thinkgem.jeesite.modules.product.service.product.GenProductService;

/**
 * 商品缺货管理Controller
 * @author Egan
 * @version 2016-12-12
 */
@Controller
@RequestMapping(value = "${adminPath}/order/stock/manage")
public class OrderStockController extends BaseController {

	@Autowired
	GenProductService genProductService;
	
	@Autowired
	GenCatalogService genCatalogService;
	
	@RequiresPermissions("order:stock:manage:view")
	@RequestMapping(value = {"list", ""})
	public String list(GenProduct genProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
		
		List<GenCatalog> genCatalogs = genCatalogService.findList(null);
		model.addAttribute("genCatalogs", genCatalogs);
		
		Page<GenProduct> page = genProductService.findPageStockOut(new Page<GenProduct>(request, response), genProduct); 
		model.addAttribute("page", page);
		return "modules/shop/stock/shopDispatchStockout";
	}
	
	@RequiresPermissions("order:stock:manage:view")
	@RequestMapping(value = "form")
	public String form(GenProduct genProduct, Model model) {
		model.addAttribute("genProduct", genProduct);
		return "modules/shop/stock/form";
	}
}